<html>
<head>
	<script type="text/javascript">
		var wsdlURL		= "server-side/wsdl/wsdl.action.php";					//server side folder url
		var fName 		= "sync-form";
		
		$(document).ready(function () {
			LoadDialog();
		});
		
		function LoadDialog(){
			GetDate("start");
			GetDate("end");
			var defoult = {
		        "save": {
		            text: "სინქრონიზაციის დაწყება",
		            id: "save-dialog",
		            click: function () {
		            }
		        }		    
			};
		    
		    $("#" + fName).dialog({
		        resizable:     false,
		        draggable:     false,		       
		        width:         800,
		        height:        480,
		        modal:         false,
		        stack:         true,
	            sticky:        false,
	            closeOnEscape: false,
	            dialogClass:   "pos-dialog",
	            buttons:       defoult 
		    });
		}
		
        $(document).on("click", "#save-dialog", function() {
        	SyncRS();
        });
        
		function SyncRS(){
			param 					= new Object();
			param.act				= "sync";
			param.create_date_s		= $("#start").val();
			param.create_date_e		= $("#end").val();
			param.waybill_number	= $("#waybill_number").val();
			param.seller_tin		= $("#seller_tin").val();
			
			$.ajax({
		        url: wsdlURL,
        		data: param,
		        success: function(data) {
					if(typeof(data.error) != "undefined"){
						if(data.error != ""){
							alert(data.error);
						}else{
							alert("სინქრონიზაცია წარმატებით დასრულდა!!!");
						}
					}
			    }
			});
		}
    </script>
</head>

<body>
	<div id="sync-form" title="სინქრონიზაცია">
		<div id="dialog-form">
			<fieldset>
				<legend>სინქრონიზაცია ზედნადებით</legend>
				<table width="52%" class="dialog-form-table">
					<tr>
						<td style="width: 170px;"><label for="name">ზედნადების ნომერი</label></td>
					</tr>
					<tr>
						<td><input type="text" id="waybill_number" class="idle" onblur="this.className='idle'" onfocus="this.className='activeField'" value=""/></td>
					</tr>
				</table>
			</fieldset>	
			<fieldset>
				<legend>სინქრონიზაცია მომწოდებლით</legend>
				<table width="52%" class="dialog-form-table">
					<tr>
						<td style="width: 170px;"><label for="name">მომწოდებლის ნომერი</label></td>
					</tr>
					<tr>
						<td><input type="text" id="seller_tin" class="idle" onblur="this.className='idle'" onfocus="this.className='activeField'" value=""/></td>
					</tr>
				</table>
			</fieldset>	
			<fieldset>
				<legend>სინქრონიზაცია დროით</legend>
				<table width="52%" class="dialog-form-table">
					<tr>
						<td style="width: 170px;"><label for="tin">დასაწყისი</label></td>
						<td style="width: 170px;"><label for="name">დასასრული</label></td>
					</tr>
					<tr>
						<td><input type="text" id="start" class="idle" onblur="this.className='idle'" onfocus="this.className='activeField'" value=""/></td>
						<td><input type="text" id="end" class="idle" onblur="this.className='idle'" onfocus="this.className='activeField'" value=""/></td>
					</tr>
				</table>
			</fieldset>
		</div>
	</div>
</body>
</html>